<template>
  <div>
    <ali-player
      v-if="playAuth"
      :vid="vid"
      :playauth="playAuth"
      ref="player"
      :height="height"
    ></ali-player>
  </div>
</template>

<script>
import VueAliplayer from "../ali-player/ali-player";
export default {
  data() {
    return {
      playAuth: "",
    };
  },
  components: {
    "ali-player": VueAliplayer,
  },
  props: {
    // 接收父组件的数据
    mp4Pic: {
      type: String,
      defaule: "0",
    },
    mp4Url: {
      type: String,
      defaule: "0",
    },
    islike: {
      type: String,
      defaule: "0",
    },
    vParams: {
      type: Object,
      defaule: "0",
    },
  },
  computed: {
    height() {
      let width = document.documentElement.clientWidth;

      return `${width / 1.7777778}px`;
    },
  },
  watch: {},
  created() {},
  mounted() {
    this._getPlayAuth(this.vParams);
  },
  methods: {
    // play(){
    //     const player = this.$refs.player.instance
    //     player && player.play()
    // },
    // 获取视频鉴权地址
    _getPlayAuth(val) {
      this.$fetch.video
        .auth({
          videoId: val,
        })
        .then((res) => {
          this.playAuth = res.data;
        });
    },
  },
};
</script>

<style lang="scss" scoped></style>
